package com.cesgroup.zw.spring.boot.library.echarts.pie.many;

import com.cesgroup.zw.spring.boot.charts.model.IChartsParam;
import com.cesgroup.zw.spring.boot.charts.model.IComponent;
import lombok.Builder;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ytj
 * @date 2019/7/10 9:45
 */
@Builder
@Data
@SuppressWarnings("serial")
public class ManyPieParam implements IChartsParam<ManyPieSeries,Map<Object,Object[]>> {
    private Map<Object,Object[]> dataset;

    @Override
    public IComponent[] getSeries() {
        Object[] names=this.dataset.get("name");
        Object[] values=this.dataset.get("value");
        Object[][] colors=(Object[][]) this.dataset.get("color");
        ManyPieSeries[] series=new ManyPieSeries[names.length];
        for(int i=0;i<names.length;i++){
            Object color1=colors[i][0];
            Object color2=colors[i][1];
            String name=names[i]+"";
            String value=values[i]+"";
            series[i]=new ManyPieSeries(i,name,value,color1,color2);
        }
        return series;
    }
}
